import { timestampMeta, startLoading } from 'shared/utils/reducerUtil';
import * as actionTypes from '../consts';
import API from '../api';
// param={keyword:''}
/** 获取接口数据 */
export const getDatas = (param, pager) => (dispatch) => {
  /** 标记加载中 */
  dispatch(startLoading(actionTypes.getDatas));
  /** 发起接口数据请求 */
  dispatch({
    type: actionTypes.getDatas,
    payload: API.getDatas(param, pager),
    // 调用timestampMeta，支持处理同一个请求的先后顺序问题
    meta: timestampMeta({
      param: { param, pager },
      handlers: {
        success: () => {
        },
        failed: () => {
        }
      }
    }),
  });
};
